using GalaSoft.MvvmLight;

namespace SfdClient.ViewModel
{
    public abstract class WorkingViewModelBase : ViewModelBase
    {
        #region IsWorking Property

        /// <summary>
        /// The <see cref="IsWorking" /> property's name.
        /// </summary>
        public const string IsWorkingPropertyName = "IsWorking";

        private bool _isWorking;

        public bool IsWorking
        {
            get { return _isWorking; }

            private set
            {
                if (_isWorking == value) return;

                bool oldValue = _isWorking;
                _isWorking = value;

                RaisePropertyChanged(IsWorkingPropertyName, oldValue, _isWorking, true);
            }
        }

        #endregion

        #region WorkingMessage Property

        /// <summary>
        /// The <see cref="WorkingMessage" /> property's name.
        /// </summary>
        public const string WorkingMessagePropertyName = "WorkingMessage";

        private string _workingMessage;

        public string WorkingMessage
        {
            get { return _workingMessage; }

            private set
            {
                if (_workingMessage == value) return;

                _workingMessage = value;
                RaisePropertyChanged(WorkingMessagePropertyName);
            }
        }

        #endregion  

        public void MarkWorking(string workingMessage)
        {
            IsWorking = true;
            WorkingMessage = workingMessage;
        }

        public void MarkNotWorking()
        {
            IsWorking = false;
            WorkingMessage = null;
        }

        public void MarkNotWorking(string workingMessage)
        {
            IsWorking = false;
            WorkingMessage = workingMessage;
        }
    }
}